import { deepCopyObject } from '../../utils/normalUtils'

let testId = 0

const createTestId = () => {
    testId += 1
    return testId
}

const loginMock = async () => {
    return {
        loginFlag: 'success',
        promptMessage: '',
        token: 'sss',
        userId: 'dfdfdf'
    }
}

const listMock = async () => {
    return {
        countId: '',
        current: 0,
        hitCount: true,
        maxLimit: 0,
        optimizeCountSql: true,
        orders: [
            {
                asc: true,
                column: ''
            }
        ],
        pages: 0,
        records: createTestData({
            createTime: '2020-01-01 00:00:00',
            createUser: 0,
            id: 0,
            memberName: '辅导费',
            number: 333,
            orderPayTime: '2020-01-01 00:00:00',
            orderStatus: 'dfd',
            price: 3333,
            productName: '大幅度发',
            unit: '元'
        }),
        searchCount: true,
        size: 0,
        total: 0
    }
}

const dealerListMock = async () => {
    return createTestData(
        {
            id: 0,
            level: 0,
            name: '名称大幅度发到付',
            children: createTestData({
                id: 0,
                level: 0,
                name: '名称大幅度发到付'
            }, 2)
        }
    )
}

const ssss = async () => {
    return {
        computeVOList: createTestData({
            bossMakeCommission: 222,
            makeCommission: 22,
            memberName: '大幅度',
            number: 3333,
            point: 333,
            productName: '大幅度'
        }),
        makeCommission: 0,
        memberName: '',
        orderPayTimeEnd: '',
        orderPayTimeStart: ''
    }
}


const ddd = async () => {
    return {
        countId: '',
        current: 0,
        hitCount: true,
        maxLimit: 0,
        optimizeCountSql: true,
        orders: [
            {
                asc: true,
                column: ''
            }
        ],
        pages: 0,
        records: createTestData({
            id: 0,
            name: '大幅度发的',
            pointOne: 333,
            pointTwo: 555
        }),
        searchCount: true,
        size: 0,
        total: 200
    }
}

const successMock = async () => {
    return {}
}

function createTestData(obj:any, len = 30) {
    const re = []
    for (let i = 0; i < len; i++) {
        const item = deepCopyObject(obj)
        item.id = createTestId()
        re.push(item)
    }
    return re
}

export default {
    // '/login': loginMock
    // '/order': listMock,
    // '/personnel': dealerListMock,
    // '/order/excel': successMock,
    // '/order/compute': ssss,
    // '/productPointConfig': ddd
}
